<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<link rel="stylesheet" type="text/css" href="../../../Themes/default/easyui.css">
		<link rel="stylesheet" type="text/css" href="../../../Themes/icon.css">
		<link rel="stylesheet" type="text/css" href="../../../CSS/demo.css">
		<link rel="stylesheet" type="text/css" href="../../../CSS/common.css">
	</head>

	<body style="padding: 0px;">
		<div id="toolbar" class="receipts_toolbar_style"></div>
		<form id="ff">
			<table id="basicInfo" class="displaytable" style="text-align: left;padding:20px;">
				<tr>
					<td width="15%">姓名</td>
					<td width="35%">
						<input type="text" style="width: 80%" class="easyui-textbox" data-options='required:true' id="input_NAME" name="NAME" />
					</td>
					<td width="15%">性别</td>
					<td width="35%">
						<input type="text" style="width: 80%" class="easyui-combobox" id="input_GENDER" name="GENDER" data-options="required:true" />
					</td>
				</tr>
				<tr>
					<td width="15%">电话</td>
					<td width="35%">
						<input type="text" style="width: 80%" class="easyui-textbox chechkPhone" data-options='required:true' id="input_TELEPHONE" name="TELEPHONE" />
					</td>
					<td width="15%">身份证号码</td>
					<td width="35%">
						<input type="text" style="width: 80%" class="easyui-textbox checkIdcard" data-options='required:true' id="input_IDCARD" name="IDCARD" />
					</td>
				</tr>
			</table>
			<div id="new_footer" style="background-color:#D2E0F2;"></div>
		</form>
		<script type="text/javascript" src="../../../JS/jquery.min.js"></script>
		<script type="text/javascript" src="../../../JS/jquery.easyui.min.js"></script>
		<script type="text/javascript" src="../../../JS/common.js"></script>
		<script type="text/javascript" src='../../../JS/SHA-1.js'></script>
		<script type="text/javascript" src="../../../JS/MarketShareFunction/DialogShareFunction.js"></script>
	</body>
	<script type="text/javascript">
		var content;
		var id = getID();
		var currid;
		var MaxPage;
		var MinPage;
		var currPage;
		var isVerify;
		var AddDialog;
		var receipts_type = RECEIPT_SAVE_SYMBOL;
		receipts_type += RECEIPT_ADD_SYMBOL + RECEIPT_NEXT_SYMBOL + RECEIPT_FRONT_SYMBOL + RECEIPT_DELETE_SYMBOL;
		receipts_type += RECEIPT_UNVERIFY_SYMBOL + RECEIPT_VERIFY_SYMBOL + RECEIPT_PRINT_SYMBOL + RECEIPT_CHARGE_SYMBOL;
		content = AddReceiptsToolBar(receipts_type, "");
		$("#toolbar").append(content);
		addDialogFooter($("#new_footer"));
		getPageMaxAndMin();

		initCombobox();
		$(document).ready(function(){
		if(id != AddFlag) {
			currid = id;
			loadRemote();
		} else {
			currid = AddFlag;
		}
        });
		function loadRemote() {
			var _url = RemoteLinkAddress + '/market/tenant/findbyid.do?ID=' + currid;
			getRemoteData(_url);
		}

		function frontpage() {
			if(currid == AddFlag) {
				currid = currPage;
			}
			if(currid <= MinPage) {
				$.messager.alert("消息", "没有上张");
				return;
			}
			var _url = RemoteLinkAddress + '/market/tenant/pre.do?TYPE=1&ID=' + currid;
			getRemoteData(_url);
		}

		function nextpage() {
			if(currid == AddFlag) {
				currid = currPage;
			}
			if(currid >= MaxPage) {
				$.messager.alert("消息", "没有下张");
				return;
			}
			var _url = RemoteLinkAddress + '/market/tenant/next.do?TYPE=1&ID=' + currid;
			getRemoteData(_url);
		}

		//链接到收费管理
		function charge() {
			var pLocation = "UI/Market/Receipt/receiptAdd.html?type=tenant&ID=" + currid;
			AddTabIn("收费管理", parent.parent.$("#tabs"), pLocation);
		}

		function newdata() {
			$("#verifydisplay").empty(); //去掉审核或者未审核的图片
			isVerify = 0; //将状态改为未审核
			currid = AddFlag;
			resetData();
		}

		function save() {
			var tip;
			tip = isTrueData();
			if(tip != "验证成功") {
				$.messager.alert("错误", tip);
				return;
			}
			tip = checkDataFormat();
			if(tip != "验证成功") {
				$.messager.alert("错误", tip);
				return;
			}
			var _url;
			if(currid == AddFlag) {
				_url = RemoteLinkAddress + "/market/tenant/save.do";
			} else {
				if(isVerify == 1) {
					$.messager.alert("警告", "表单已审核不能修改!");
					return;
				}
				_url = RemoteLinkAddress + "/market/tenant/update.do";
			}
			saveData(_url);
		}

		function deletedata() {
			if(currid == AddFlag) {
				$.messager.alert("警告", "新增页面，无法执行");
				return;
			}
			if(isVerify == 1) {
				$.messager.alert("警告", "订单已审核，无法删除");
				return;
			}
			$.messager.confirm("确认", "是否删除", function(r) {
				if(r) {
					$.post(RemoteLinkAddress + "/market/tenant/delete.do", {
						"ID": currid,
					}, function(result) {
						if(result.msg == "success") {
							$.messager.alert({
								title: '成功',
								msg: '删除成功!'
							});
							nextpage();
							reloadList();
						} else {
							$.messager.alert({
								title: 'Error',
								msg: result.msg
							});
						}
					}, 'json');
				}
			});
		}

		function verifydata() {
			if(currid == AddFlag) {
				$.messager.alert("警告", "新增页面，无法执行");
				return;
			}
			if(isVerify == 1) {
				$.messager.alert("警告", "订单已审核，无须再审");
				return;
			}
			$.messager.confirm("确认", "是否审核", function(r) {
				if(r) {
					$.post(RemoteLinkAddress + "/market/tenant/verify.do", {
						"ID": currid,
					}, function(result) {
						if(result.msg == "success") {
							$.messager.alert({
								title: '成功',
								msg: '审核成功!'
							});
							verifyStatus_Market(1, true);
							isVerify = 1;
							reloadList();
						} else {
							$.messager.alert({
								title: 'Error',
								msg: result.msg
							});
						}
					}, 'json');
				}
			});
		}

		function unverifydata() {
			if(currid == AddFlag) {
				$.messager.alert("警告", "新增页面，无法执行");
				return;
			}
			if(isVerify == 0) {
				$.messager.alert("警告", "订单已弃审，无须再审");
				return;
			}
			$.messager.confirm('Confirm', '是否弃审', function(r) {
				if(r) {
					$.post(RemoteLinkAddress + "/market/tenant/unverify.do", {
							"ID": currid,
						},
						function(result) {
							if(result.msg == "success") {
								$.messager.alert({
									title: '成功',
									msg: '放弃审核成功!'
								});
								verifyStatus_Market(0, true);
								isVerify = 0;
								reloadList();
							} else {
								$.messager.alert({
									title: 'Error',
									msg: result.msg
								});
							}
						},
						'json');
				}
			});
		}

		function print() {
			if(currid == AddFlag) {
				$.messager.alert("警告", "当前为新增页面，不能打印");
				return;
			}
			if(isVerify == 0) {
				$.messager.alert("警告", "订单未审核，不能打印");
				return;
			}
			window.open("SmallBusinessInformationPrint.html?id=" + currid);
		}

		function getPageMaxAndMin() {
			var _url = RemoteLinkAddress + "/market/tenant/getmaxminid.do";
			$.ajax({
				type: "get",
				url: _url,
				dataType: "json",
				success: function(result) {
					if(result != null) {
						MaxPage = result.MAXID;
						MinPage = result.MINID;
						currPage = MinPage + 1;
					}
				},
				error: function(xhr, status, error) {
					$.messager.alert("错误", "请求失败!");
				}
			});
		}

		function getRemoteData(_url) {
			$.ajax({
				type: "get",
				url: _url,
				dataType: "json",
				success: function(result) {
					if(result != null) {
						if(result.msg === "nextnull") {
							$.messager.alert("消息", "没有下张");
							return;
						}
						if(result.msg === "prenull") {
							$.messager.alert("消息", "没有上张");
							return;
						}
						isVerify = result.ISVERIFY;
						currid = result.ID;
						currPage = result.ID;
						getDialogData(result);
						verifyStatus_Market(isVerify, true);
					}
				}
			});
		}

		function saveData(_url) {
			var _data = submitDialogData();
			if(currid == AddFlag) {
				_data.TYPE = "1";
			}
			if(currid != AddFlag) {
				_data.ID = currid;
			}
			$.ajax({
				type: "post",
				url: _url,
				dataType: "JSON",
				data: _data,
				success: function(result) {
					if(result.msg.search("success") > -1) {
						reloadList();
						var parentLocation;
						parentLocation = searchParent("SmallBusinessInformationList.html");
						parentLocation.dialogClose();
						$.messager.alert('提示信息', '保存成功!');

					} else {
						$.messager.alert("提示信息", "保存失败");
					}
				},
				error: function(result) {
					$.messager.alert('提示信息', '保存失败');
				}
			});
		}

		//刷新list页面
		function reloadList() {
			var parentLocation;
			parentLocation = searchParent("SmallBusinessInformationList.html");
			data = parentLocation.redodata();
		}
	</script>

</html>